<%@ page language="java" isELIgnored="false"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>私教课程管理</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link href="/admin/public/inspinia.css" rel="stylesheet" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" />
<link href="/admin/public/animate.css" rel="stylesheet" />
<link href="/admin/css/plugins/chosen/chosen.css" rel="stylesheet">
<link
	href="/admin/css/plugins/datetimepicker/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen" />
<link href="/admin/public/zTree/css/zTreeStyle/zTreeStyle.css"
	rel="stylesheet" />
<link href="/admin/js/multipleselect/multiple-select.css"
	rel="stylesheet" />
<link rel="stylesheet" href="/admin/css/Tab_swiper.css" />
<link rel="stylesheet" href="/admin/css/new_page_if.css" />
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
	<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<script src="/admin/My97/WdatePicker.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<!-- 高德地图 -->
<link rel="stylesheet"
	href="http://cache.amap.com/lbs/static/main1119.css" />
<!-- 本地 -->
<script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.3&key=064fca579fe2d6c213c9c416d17b0a60&plugin=AMap.Autocomplete"></script>
<!-- 百度编译器 -->
<script type="text/javascript" charset="utf-8" src="/admin/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/admin/js/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="/admin/js/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/admin/js/ueditor.all.min.js"></script>
<style>

th.prev {
	background: url(img/dateleft.png) -3px !important;
}

th.next {
	background: url(img/dateright.png) -10px !important;
}
.img{
	height: 130px;
	width:450px;
}
</style>
</head>
<body>
	<div
		style="width: 20px; height: 100%; position: relative; left: 16px; box-shadow: -5px 0 20px #8e9092;">
	</div>
	<div class="container-frame-detail" id="containerDetail"
		style="display: block; right: 0px; width: 780px; position: relative; bottom: 100%; left: 16px; height: 100%;">
		<div class="detail-inner" id="detailInner">
			<div class="slid-panel-header clearfix">
				<span class="panel-title">修改私教</span> <span class="form-close-icon"></span>
			</div>
				<input type="hidden" value="${userId }" id="uuId">
			<div class="detail_left">
				<div class="detail_left_inner">
					<div class="customer_tabs fn-clear"
						style="margin-right: 30px; margin-left: 10px;">
						<ul class="detail_main_nav">
							<li><a class="slide-panel-tab slide_nav_hover"
								href="javascript:void(0)">修改私教</a></li>
						</ul>
						<div class="detail_panels_main_body">
							<div id="renWu_msg" class="active">
								<form class="form-horizontal" method="post" id="savecourses" enctype="multipart/form-data"
							novalidate="novalidate">
							<input value="1" name="coursesType" type="hidden" />
							<input value="${coursesInfoId }" name="coursesInfoId" type="hidden" />
							<input value="${picUrl }" name="oldPicUrl" type="hidden" />
							<div class="form-group">
								<label class="col-lg-2 control-label">私教课程:</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="coursesName"
										name="coursesName" value="${coursesName }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">时长(分钟):</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="minTime"
										name="minTime" value="${minTime }"/>
								</div>
							</div>
							<div style="display: none">
							<div class="form-group">
								<label class="col-lg-2 control-label">背景图片:</label>
								<div class="col-lg-6">
									<input type="file" class="form-control" id="picUrl"
										name="picUrl" value="${picUrl }" onchange="preview(this,1)">
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label"></label>
								<div class="col-lg-6">
									<span style="color:red;">建议图片尺寸：640*214</span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label"></label>
								<div class="col-lg-6">
									<div id="preview1">
										<img src="${picUrl }" alt="" height="214px" width="640px"/>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">如何上课:</label>
								<div class="col-lg-6">
									<script id="editor" type="text/plain" name="rhsk"  style="width:504px;height:200px;">${rhsk }</script>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">课程标签:</label>
								<div class="col-lg-6">
									<textarea  rows="3" cols="3" class="form-control" id="jianjie"
										name="jianjie" >${jianjie }</textarea>
								</div>
							</div>
							</div>
							<div class="form-group" style="height:100px;">
								<label class="font-noraml" style="margin-left: 20px;">关联教练:</label>
								<div class="input-group" style="margin-left: 90px;margin-top: -30px;">
									<select id="glCoatch" data-placeholder="--请选择--" class="chosen-select" multiple style="width:350px;" tabindex="4">
										<c:forEach items="${elist }" var="item">
											<option value="${item.userId }">${item.realname }</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<input type="button" onclick="update();" value="修改" style="width: 82px; height: 34px; margin-left: 50%;margin-top: -20%;" class="col-lg-3 btn btn-success" />
						</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/js/jquery.form.min.js"></script>
	<script src="/admin/js/plugins/lhgdialog/lhgdialog.js"></script>
	<!-- 时间控件样式 -->
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker-update.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
	<!-- 弹出框 -->
	<script src="/admin/js/multipleselect/multiple-select.js"></script>
	<script src="/admin/js/plugins/chosen/chosen.jquery.js"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	<!--    <script src="/admin/js/Tab_swiper.js"></script>-->
	<script src="/admin/js/new_page_if.js"></script>
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<script type="text/javascript">
		function preview(file, i) {
			var prevDiv = document.getElementById('preview' + i);
			//隐藏之前的图片
			$("#old"+i).html("");
			if (file.files && file.files[0]) {
				var reader = new FileReader();
				reader.onload = function(evt) {
					prevDiv.innerHTML = '<img class="img" src="' + evt.target.result + '" />';
				}
				reader.readAsDataURL(file.files[0]);
			} else {
				prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
			}
		}
	</script>
	<script type="text/javascript">
	var uuId=$("#uuId").val();
	var strs= new Array(); //定义一数组 
	strs=uuId.split(","); //字符分割 
	for (c=0;c<strs.length ;c++){
		$("#glCoatch option[value='"+strs[c]+"']").attr("selected",true);
		//alert($("#glCoatch option:selected").val())
	} 
	var config = {
			'.chosen-select': {},
			'.chosen-select-deselect': {
				allow_single_deselect: true
			},
			'.chosen-select-no-single': {
				disable_search_threshold: 10
			},
			'.chosen-select-no-results': {
				no_results_text: 'Oops, nothing found!'
			},
			'.chosen-select-width': {
				width: "95%"
			}
		}
		for(var selector in config) {
			$(selector).chosen(config[selector]);
		}
	function check() {
		var coursesName = $("#coursesName").val();
		var minTime = $("#minTime").val();
		var minNum = $("#minNum").val();
		var maxNum=$("#maxNum").val();
		var userIdlength=$(".chosen-container .chosen-choices .search-choice span").length;
		if (coursesName.length == 0) {
			alert('请输入私教课名称！', false);
			return false;
		}
		if (minTime.length == 0) {
			alert('请输入最少时长！', false);
			return false;
		}
		if (userIdlength == 0) {
			alert('请选择关联教练！', false);
			return false;
		} 
		return true;
	}
		function update() {
			if (check()) {
				var len=$(".chosen-container .chosen-choices .search-choice span").length;
				var zhi=""
				var zhi2=""
				for(var i=0;i<len;i++){
					zhi2=$(".chosen-container .chosen-choices .search-choice span").eq(i).data("value");
					if(i==0){
						zhi=zhi2;
					}else{
						zhi += ("," +zhi2);
					}
				}
				$('#savecourses').ajaxSubmit({
					type : "post",
					data : {"userId":zhi},
					dataType : "json",
					enctype:"multipart/form-data",
					url : "/courses/updatecourses",
					success : function(data) {
						if (data.success) {
							window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
								window.parent.location.href="/courses/cournfo?coursesType=1";
					  		}})
						}else{
							alertNew(data.msg, false);
						}
					},
					error : function(data) {
						alert("很抱歉，未知的错误发生了！");
					}
				});
			}
		}
		 /**文本编辑器**/
        //实例化编辑器
 //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
  var ue = UE.getEditor('editor', {
 	 	"imageActionName": "uploadimage", /* 执行上传图片的action名称 */
 	    "imageFieldName": "upfile", /* 提交的图片表单名称 */
 	    "imageMaxSize": 2048000, /* 上传大小限制，单位B */
 	    "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
 	    "imageCompressEnable": false, /* 是否压缩图片,默认是true */
 	    "imageCompressBorder": 1600, /* 图片压缩最长边限制 */
 	    "imageInsertAlign": "none", /* 插入的图片浮动方式 */
 	    "imageUrlPrefix": "", /* 图片访问路径前缀 */
 	    "imagePathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
 	                                /* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
 	                                /* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
 	                                /* {time} 会替换成时间戳 */
 	                                /* {yyyy} 会替换成四位年份 */
 	                                /* {yy} 会替换成两位年份 */
 	                                /* {mm} 会替换成两位月份 */
 	                                /* {dd} 会替换成两位日期 */
 	                                /* {hh} 会替换成两位小时 */
 	                                /* {ii} 会替换成两位分钟 */
 	                                /* {ss} 会替换成两位秒 */
 	                                /* 非法字符 \ : * ? " < > | */
 	                                /* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */
 	                                
			    	   /* 上传视频配置 */
			    "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
			    "videoFieldName": "upfile", /* 提交的视频表单名称 */
			    "videoPathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
			    "videoUrlPrefix": "", /* 视频访问路径前缀 */
			    "videoMaxSize": 734003200, /* 上传大小限制，单位B，默认100MB 此处限制700M*/
			    "videoAllowFiles": [
			        ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
			        ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */
 	        
 	        /* 上传文件配置 */
 	        "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
 	        "fileFieldName": "upfile", /* 提交的文件表单名称 */
 	        "filePathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
 	        "fileUrlPrefix": "", /* 文件访问路径前缀 */
 	        "fileMaxSize": 51200000, /* 上传大小限制，单位B，默认50MB */
 	        "fileAllowFiles": [
 	            ".png", ".jpg", ".jpeg", ".gif", ".bmp",
 	            ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
 	            ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
 	            ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
 	            ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
 	        ], /* 上传文件格式显示 */
 	        serverUrl: '/admin/content/uploadimage'
 });
		
	</script>
	
</body>
</html>
